<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>会员资料编辑-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../css/font.css">
		<link rel="stylesheet" href="../../css/weadmin.css">
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	    
	    <script src="../../js/jquery-3.1.1.js"></script>
	    <script src="../../js/formSelects-v3.js"></script>
	</head>

	<body>
		<div class="weadmin-body">
			<form class="layui-form">
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">
		                <span class="we-red">*</span>节点IP
		            </label>
					<div class="layui-input-inline">
						<input type="text" readonly="readonly" id="nodeIP" name="ip"  autocomplete="off" class="layui-input">
					</div>
					
				</div>
			    <div class="layui-form-item">
				    <label class=" layui-form-label"><span class="we-red">*</span>选择规约</label>
				    <div class=" layui-input-inline">
				        <select id="strategySelect" xm-select="select" xm-select-type="1" >
							
						</select>
				    </div>
				    <div class="layui-form-mid layui-word-aux">
						自动开启关闭节点规约解析类型
					</div>
				 </div>
				
				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label">
             		</label>
					<button class="layui-btn"  lay-filter="add" lay-submit="">确定</button>
					<input type="hidden" name="dataId" id="dataId" value="" />
				</div>
			</form>
		</div>
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript">
			var localCache = [];
			
			//从后台获取初始化下拉框数据
			function loadStrategy(){
				
			}
			function child(data){
				localCache = data;
				$.post("/rpc/getAllStrategeFromDB", 
					function(data){
						//赋值
						var map = data.data[0];
						var str = "<option value=\"\"></option>";
						for(var k in map){  
							var val=map[k]; 
							str += "<option value=\""+val+"\">"+k+"</option>";
						}
						$("#strategySelect").html(str);
						
						
						layui.config({
							base: './'
						}).extend({
							formSelects: '../../js/formSelects-v3'
						}).use(['form', 'formSelects'], function() {
							var form = layui.form,
							formSelects = layui.formSelects;
							      
							//var val1=formSelects.value('select');			//获取选中的值
							//var val2=formSelects.value('select', 'val');		//获取选中的val数组
							//var val3=formSelects.value('select', 'name');	//获取选中的name数组
							formSelects.value('select', localCache);	//动态赋值
							
							
							//监听提交
							form.on('submit(add)', function(data) {
								console.log(data);
								//发异步，把数据提交给php
								var val1=formSelects.value('select', 'val');
								var ss = "";
								for(var i=0;i<val1.length;i++){
									ss+=(val1[i]+",");
								}
								var objs = JSON.stringify( val1 )
								debugger
								$.post("/rpc/updateStrategyNode",{"dataList":ss.substring(0,ss.length-1),"str":$("#nodeIP").val()} ,
									function(data){
										if(data.retSig == 200){
											layer.alert("操作成功！", {
												icon: 6
											}, function() {
												//刷新父页面
												window.parent.location.reload();
												// 获得frame索引
												var index = parent.layer.getFrameIndex(window.name);
												//关闭当前frame
												parent.layer.close(index);
											});
										}
									},"json"
								);
								
								return false;
							});
						});
						
					}
				);
				
				
				
			}
			$(function(){
				
			})
		</script>
	</body>

</html>